package com.lzclass.servlet.adminservlet;

import com.alibaba.fastjson.JSON;
import com.lzclass.service.adminservice.UserService;
import com.lzclass.util.JwtUtil;
import com.lzclass.util.OssServiceUtil;
import com.lzclass.util.ServiceUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@WebServlet("/addarticle")
public class addArticleByUid extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html; charset=utf-8");
        int uid = Integer.valueOf(req.getParameter("uid"));
        String title = req.getParameter("title");
        String contexts = req.getParameter("contexts");
        String type = req.getParameter("type");
        String img = req.getParameter("img");
        String time = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss").format(new Date());

            int ge = ((UserService) ServiceUtil.getService("userServiceImpl")).addArticleByUid(uid, title, contexts, type, img, time);
            resp.getWriter().write("添加成功！");


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
